package com.hnjowe.util;


import org.apache.log4j.PropertyConfigurator;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class Log4jInit extends HttpServlet {
	
	private static final long serialVersionUID = 872312255505389L;

	public void init(){
		//通过web.xml来动态取得配置文件
		String prefix = getServletContext().getRealPath("/");
		String file = getInitParameter("log4j-init-file");		
		
		// 如果没有给出相应的配置文件，则不进行初始化
		if(file != null){
			PropertyConfigurator.configure(prefix + file);
		}
	}
	
	public void doGet(HttpServletRequest req, HttpServletResponse res){
		
	}

}
